/**
 * Created by feimao on 15-11-30.
 */
app.controller('reservationCtrl',function($scope,$location){
    if(localStorage.list==null) var info_list=[];
    else var info_list=JSON.parse(localStorage.list);
    $scope.name=localStorage.name;
    $scope.shop=localStorage.shop;
    $scope.menu=localStorage.menu;
    $scope.price=localStorage.price;
    disabled_ctrl($scope);
    $scope.goToUrl=function(path) {
        $location.path(path);
    };
    $scope.takeUp=function(){
        var info=obj_info($scope);
        info_list.push(info);
        localStorage.list=JSON.stringify(info_list);
        clear_show_info($scope);
        disabled_ctrl($scope);
    };
});
function obj_info($scope){
    var info={};
    info.name=$scope.name;
    info.shop=$scope.shop;
    info.menu=$scope.menu;
    info.price=$scope.price;
    return info;
}
function clear_show_info($scope){
    localStorage.name='';
    localStorage.shop='';
    localStorage.menu='';
    price=localStorage.price='';
    $scope.name='';
    $scope.shop='';
    $scope.menu='';
    $scope.price='';
}
function disabled_ctrl($scope){
    if(!$scope.shop){
        document.getElementById("choose_menu").disabled=true;
    }
    if(!$scope.name||!$scope.menu){
        document.getElementById("save").disabled=true;
    }
}